﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DwarfInterpreter
{
    abstract class Token
    {
        public enum TokenType
        {
            DwarfCommand,
            Repetition,
            Variable,
            UnknownToken
        }
        
        virtual public void Run(Dwarf dwarf) { }

        public static Token CreateToken(string[] symbols)
        {
            if (
                    StringUtils.IsSimpleString(symbols[0]) && 
                    (symbols.Length == 1) && 
                    DwarfToken.IsDwarfCommand(symbols[0])
                )
            {
                return new DwarfToken(symbols[0]);
            }

            if (                    
                    (symbols.Length == 2) &&
                    SelectToken.IsSelectCommand(symbols)
                )
            {
                return new SelectToken(symbols[1]);
            }

            if (                    
                    (symbols.Length == 2) &&
                    UseFileToken.IsUseFileCommand(symbols)
                )
            {
                return new UseFileToken(symbols[1]);
            }

            if (
                    (symbols.Length == 2) &&
                    UseFileToken.IsUseFileCommand(symbols)
                )
            {
                return new UseFileToken(symbols[1]);
            }

            if (
                    WhileToken.IsWhileToken(symbols)
                )
            {
                return new WhileToken(symbols);
            }

            return new NullToken();
        }


    }
}
